<?php
/*
 * Created on 03.01.2006
 *
 */

class URL
{
    
    var $value;
    var $params;
    var $action;
    var $anquor;

    function URL ($value = '')
    {
        $this->value = $value;
    }
    
    function addParam ($name, $value)
    {
        $this->params[] = array($name, $value);
    }
    
    function setAction($action)
    {
        $this->action = $action;
    }
    
    function setAnquor($a)
    {
        $this->anquor = $a;
    }
    
    function toString ()
    {
        $paramstr = "";
        for ($i = 0; $i < count ($this->params); $i++)
        {
            if ($i != 0)
                $paramstr .= "&";
            $paramstr .= join("=", $this->params[$i]);
        }
        $url = $this->value;
        if ($this->action || $paramstr)
        {
            $url .= '?';
        }
        if ($this->action)
        {
            $url .= 'nestedaction='.$this->action;
        }
        if ($paramstr)
        {
            if ($this->action)
                $url .= '&';
            $url .= $paramstr;
        }
        if ($this->anquor)
            $url .= '#'.$this->anquor;
        return $url;
    }

}

?>
